<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //给 Array  扩展一个方法 mySort （冒泡排序） 作业  ,按照 数值大小进行排序
        Array.prototype.mySort = function() {
            for (var i = 0; i < this.length - 1; i++) {
                for (var j = 0; j < this.length - 1 - i; j++) {
                    if (this[j] > this[j + 1]) {
                        var tamp = this[j];
                        this[j] = this[j + 1];
                        this[j + 1] = tamp;
                    }
                }
            }
            return this;
        }
        var b = [234, 453, 324, 341, 21, 1];
        console.log(b.mySort());
    </script>
</body>

</html>